package com.ruoyi.web.controller.ydz;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.OldDrugDisease;
import com.ruoyi.web.service.IOldDrugDiseaseService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 药品疾病关联Controller
 * 
 * @author drx
 * @date 2024-03-06
 */
@Controller
@RequestMapping("/ydz/oldDrugDisease")
@Api(tags = "药品疾病关联")
public class OldDrugDiseaseController extends BaseController
{
    private String prefix = "oldDrugDisease/oldDrugDisease";

    @Autowired
    private IOldDrugDiseaseService oldDrugDiseaseService;

    @RequiresPermissions("oldDrugDisease:oldDrugDisease:view")
    @GetMapping()
    public String oldDrugDisease()
    {
        return prefix + "/oldDrugDisease";
    }

    /**
     * 查询药品疾病关联列表
     */
    @PostMapping("/list")
    @ResponseBody
    @ApiOperation("查询药品疾病关联列表")
    public TableDataInfo list(OldDrugDisease oldDrugDisease)
    {
        startPage();
        List<OldDrugDisease> list = oldDrugDiseaseService.selectOldDrugDiseaseList(oldDrugDisease);
        return getDataTable(list);
    }

    /**
     * 导出药品疾病关联列表
     */
    @RequiresPermissions("oldDrugDisease:oldDrugDisease:export")
    @Log(title = "药品疾病关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    @ApiOperation("导出药品疾病关联列表")
    public AjaxResult export(OldDrugDisease oldDrugDisease)
    {
        List<OldDrugDisease> list = oldDrugDiseaseService.selectOldDrugDiseaseList(oldDrugDisease);
        ExcelUtil<OldDrugDisease> util = new ExcelUtil<OldDrugDisease>(OldDrugDisease.class);
        return util.exportExcel(list, "药品疾病关联数据");
    }

    /**
     * 新增药品疾病关联
     */
    @GetMapping("/add")
    @ApiOperation("新增药品疾病关联")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存药品疾病关联
     */
    @ApiOperation("新增保存药品疾病关联")
    @RequiresPermissions("oldDrugDisease:oldDrugDisease:add")
    @Log(title = "药品疾病关联", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(OldDrugDisease oldDrugDisease)
    {
        return toAjax(oldDrugDiseaseService.insertOldDrugDisease(oldDrugDisease));
    }

    /**
     * 修改药品疾病关联
     */
    @ApiOperation("修改药品疾病关联")
    @RequiresPermissions("oldDrugDisease:oldDrugDisease:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        OldDrugDisease oldDrugDisease = oldDrugDiseaseService.selectOldDrugDiseaseById(id);
        mmap.put("oldDrugDisease", oldDrugDisease);
        return prefix + "/edit";
    }

    /**
     * 修改保存药品疾病关联
     */
    @ApiOperation("修改保存药品疾病关联")
    @RequiresPermissions("oldDrugDisease:oldDrugDisease:edit")
    @Log(title = "药品疾病关联", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(OldDrugDisease oldDrugDisease)
    {
        return toAjax(oldDrugDiseaseService.updateOldDrugDisease(oldDrugDisease));
    }

    /**
     * 删除药品疾病关联
     */
    @ApiOperation("删除药品疾病关联")
    @RequiresPermissions("oldDrugDisease:oldDrugDisease:remove")
    @Log(title = "药品疾病关联", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(oldDrugDiseaseService.deleteOldDrugDiseaseByIds(ids));
    }
}
